package com.carserver.service;

import com.carserver.pojo.OrderForm;
import org.aspectj.weaver.ast.Or;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface OrderFormDao extends JpaRepository<OrderForm,Integer> {
    @Query(value = "select * from order_form where flag=0",nativeQuery = true)
    public List<OrderForm> getOrderFormByFlag0();
    @Query(value = "select * from order_form where flag=1",nativeQuery = true)
    public List<OrderForm> getOrderFormByFlag1();
    @Query(value = "select * from order_form where flag=2",nativeQuery = true)
    public List<OrderForm> getOrderFormByFlag2();
    @Query(value = "select * from order_form where flag=3",nativeQuery = true)
    public List<OrderForm> getOrderFormByFlag3();

    @Query(value = "select * from order_form where flag=4",nativeQuery = true)
    public List<OrderForm> getOrderFormByFlag4();


    //根据用户ID获取订单，给用户呈现
    @Query(value = "select * from order_form where user_id=:userid",nativeQuery = true)
    List<OrderForm> getOrderFormsByUserId(@Param("userid")Integer userid);

    //根据用户ID获取订单，给用户呈现
    @Query(value = "select * from order_form where order_id=:orderId",nativeQuery = true)
    OrderForm getOrderFormsByOrderId(@Param("orderId")String orderId);

    @Query(value = "select count(*) from order_form where evaluate=5",nativeQuery = true)
    Integer count5();
    @Query(value = "select count(*) from order_form where evaluate=4",nativeQuery = true)
    Integer count4();
    @Query(value = "select count(*) from order_form where evaluate<4",nativeQuery = true)
    Integer count3();

    @Query(value = "select count(*) from order_form where flag=0",nativeQuery = true)
    Integer count_flag0();
    @Query(value = "select count(*) from order_form where flag=1",nativeQuery = true)
    Integer count_flag1();
    @Query(value = "select count(*) from order_form where flag=2",nativeQuery = true)
    Integer count_flag2();
    @Query(value = "select count(*) from order_form where flag=3",nativeQuery = true)
    Integer count_flag3();
    @Query(value = "select count(*) from order_form where flag=4",nativeQuery = true)
    Integer count_flag4();


}
